//
//  main.c
//  auto-page
//
//  Created by fukai,caihui on 2018/11.
//  Copyright © 2018年 Cyber01. All rights reserved.
//

#include "stm32f10x.h"
#include "oled.h"
#include "pwm.h"
#include "key.h"
#include "timer_interrupt.h"
#include "user_interface.h"


//主循环状态机
typedef enum
{
	GET_INFO = 0,	//信息采集
	ANALYSE_INFO,
	SHOW_INFO,
	SEND_INFO,
}MainStatusNode;

MainStatusNode MainStatus = GET_INFO;

//硬件初始化函数
void BoardInit(void)
{
	// 设置中断优先级分组2
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
	
	SystemTimIntInit(30-1,7200-1);//系统定时器中断初始化函数
	DelayInit();	//延时函数初始化
	KeyInit();
	OledInit();
	ServoPwmInit(60000-1,20-1);//PWM频率=72000000/60000/20 = 60HZ
	SystemTimIntInit(30-1,7199);//3ms一次中断  72000000/7200=10kHZ 
}


int main()
{
	int duty =100;
	
	BoardInit();
	
	while(1)
	{
		KeyMessage.KeyValue = KeyScan();
		if(KeyMessage.KeyValue == KEY_ADD)
		{
			duty += 100;
		}
		else if(KeyMessage.KeyValue == KEY_DECREASE)
		{
			duty -= 100;
		}

		OledPrintValueI(10,1,duty1);
		OledPrintValueI(10,2,duty2);
		
	}
} 











